$("footer").load("footer.html");
$(".register-btn").click(function(){
	let pass = true;
    let rulePhone=/^1[3|4|5|7|8]\d{9}$/;
	let rulePaw=/^.{6,20}$/;
	// 账号
	if(rulePhone.test($(".register-phone").val())){
		$(".register-one").css("color","transparent");
	}else{
		$(".register-one").css("color","#ff3333");
		pass = false;
	}
	// 验证码
	if($(".register-verify-num").val() == $(".register-code").html()){
		$(".register-two").css("color","transparent");
	}else{
		$(".register-two").css("color","#ff3333");
		pass = false;
	}
	// 密码
	if(rulePaw.test($(".register-paw").val())){
		$(".register-three").css("color","transparent");
	}else{
		pass = false;
		$(".register-three").css("color","#ff3333");
	}
	// 确定密码
	if($(".register-paw-con").val() == $(".register-paw").val() && $(".register-paw-con").val()!=""){
		$(".register-four").css("color","transparent");
	}else{
		pass = false;
		$(".register-four").css("color","#ff3333");
	}
	// 协议
	console.log($(".register-agreement-case").attr("checked"));
	if($(".register-agreement-case").attr("checked") == "checked"){
		$(".register-five").css("color","transparent");
	}else{
		pass = false;
		$(".register-five").css("color","#ff3333");
	}
	if(pass == true){
		$.ajax({
			type:"POST",
			url:"php/register.php",
			data:"registerid="+$(".register-phone").val()+"&registerpaw="+$(".register-paw").val()+"",
			success: function(msg){
				logAjax(msg);
			}
	    })	
	}

})
// 创建账号
function logAjax(msg){
	if(msg==0){
		alert("账号名已经存在");
	}else{
		// $.cookie('name',$(".register-phone").val(),{expires:30});
		// newTable();
		alert("注册成功");
		$(location).attr('href', 'log.html');
	}
}

// 创建用户购物车表
// function newTable(){
// 	$.ajax({
// 		type:"GET",
// 		url:"php/newTable.php",
// 		data:"registerid="+$(".register-phone").val()+""
// 	})
// }
// 单选框点击添加checked
$(".register-agreement-case").click(function(){
	$(this).attr("checked","checked");
	$(this).unbind();
	// return false;
	
});
